home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / 3dview12.zip / DPMI.CPP < prev    next >
C/C++ Source or Header  |  1996-05-16  |  2KB  |  61 lines

  1. #include <i86.h>
  2. #include <string.h>
  3.  
  4. #include "defines.hpp"
  5.  
  6. #include "dpmi.hpp"
  7.  
  8. void* DPMI_FreeAccess ( void* Adress , DWORD Count ) {
  9.     union REGS Regs;
  10.     struct SREGS SegRegs;
  11.     memset ( &SegRegs , 0 , sizeof ( SegRegs ) );
  12.     Regs.w.ax = 0x0800;
  13.     Regs.w.bx = WORD( (DWORD)Adress >> 16 );
  14.     Regs.w.cx = WORD( (DWORD)Adress );
  15.     Regs.w.si = WORD( Count >> 16 );
  16.     Regs.w.di = WORD( Count );
  17.     int386x ( 0x31 , &Regs , &Regs , &SegRegs );
  18.     return (void*)( ( (DWORD)(Regs.w.bx) << 16 ) + Regs.w.cx );
  19. };
  20.  
  21. void DPMI_CloseAccess ( void* Adress ) {
  22.     union REGS Regs;
  23.     struct SREGS SegRegs;
  24.     memset ( &SegRegs , 0 , sizeof ( SegRegs ) );
  25.     Regs.w.ax = 0x0801;
  26.     Regs.w.bx = WORD( (DWORD)Adress >> 16 );
  27.     Regs.w.cx = WORD( (DWORD)Adress );
  28.     int386x ( 0x31 , &Regs , &Regs , &SegRegs );
  29. };
  30.  
  31. WORD DPMI_GetSelector ( void* Adress ) {
  32.     union REGS Regs;
  33.     struct SREGS SegRegs;
  34.     memset ( &SegRegs , 0 , sizeof ( SegRegs ) );
  35.     Regs.w.ax = 0x0000;
  36.     Regs.w.cx = 1;
  37.     int386x ( 0x31 , &Regs , &Regs , &SegRegs );
  38.     WORD Selector = Regs.w.ax;
  39.     Regs.w.ax = 0x0007;
  40.     Regs.w.bx = Selector;
  41.     Regs.w.cx = WORD( (DWORD)Adress >> 16 );
  42.     Regs.w.dx = WORD( (DWORD)Adress );
  43.     int386x ( 0x31 , &Regs , &Regs , &SegRegs );
  44.     Regs.w.ax = 0x0008;
  45.     Regs.w.bx = Selector;
  46.     Regs.w.cx = 0xFFFF;
  47.     Regs.w.dx = 0xFFFF;
  48.     int386x ( 0x31 , &Regs , &Regs , &SegRegs );
  49.     return Selector;
  50. };
  51.  
  52. void DPMI_FreeSelector ( WORD Selector ) {
  53.     union REGS Regs;
  54.     struct SREGS SegRegs;
  55.     memset ( &SegRegs , 0 , sizeof ( SegRegs ) );
  56.     Regs.w.ax = 0x0001;
  57.     Regs.w.bx = Selector;
  58.     int386x ( 0x31 , &Regs , &Regs , &SegRegs );
  59. };
  60.  
  61.